class Manage::PicturesController < Manage::MainController
  #skip_before_filter :verify_authenticity_token, :only=>[:create, :destroy]
  
  # POST /photos
  # POST /photos.xml
	def create
		@photo = Picture.new(params[:photo])
 
    respond_to do |format|
      if params[:photo_file]
        options = {'tempfile' => params[:photo_file], 'size'=>1000, 'filename'=>params[:Filename], 'content_type'=>'image/jpg'}
      	@photo.assetable_type = params[:assetable_type]
    		@photo.assetable_id = params[:assetable_id]
      	@photo.uploaded_data = options
      	@photo.user = current_user
        @photo.save!

        format.html { render :text=>"["+@photo.public_filename(:thumb)+"]["+@photo.id.to_s+"]" }
        format.js {} # render create.rjs
        format.xml { render :nothing => true }
      else
        if @photo.save
          flash[:notice] = 'Created'
          format.html { redirect_to root_path }
          format.xml { render :xml => @photo, :status => :created, :location => @asset }
        else
          format.html { render :action => "new" }
          format.xml { render :xml => @photo.errors, :status => :unprocessable_entity }
        end
      end
    end
	end
	
	# DELETE /photos/1
  # DELETE /photos/1.[xml|js]
  def destroy
    @photo = Picture.find(params[:id])
    @photo.destroy
 
    respond_to do |format|
      format.html { redirect_to(manage_structures_path) }
      format.xml { head :ok }
      format.js {} # render destroy.rjs
    end
  end
end
